#!/bin/bash

n=`lsof -i:8189|grep -v COMMAND |wc -l`
if [ $n -eq 0 ];then
    echo "`date +'%Y-%m-%d_%H:%M:%S'` Svnsync Client Is Not Running"

    cd /data0/scripts/svnsync; python svnsync.py &

    echo "`date +'%Y-%m-%d_%H:%M:%S'` Start Svnsync Client!"
fi

m=`ps -efl |grep svnsync|grep -v grep|grep sk_wai|wc -l`

if [ $m -ne 0 ];then

    echo "`date +'%Y-%m-%d_%H:%M:%S'` Svnsync Client is Dead,Kill Pid"

    mpid=`ps -ef |grep python|grep svnsync|grep -v grep|awk '{print $2}'` 

    kill $mpid

    echo "`date +'%Y-%m-%d_%H:%M:%S'` Start Svnsync Client"

    cd /data0/scripts/svnsync; python svnsync.py &

    echo "`date +'%Y-%m-%d_%H:%M:%S'` Svnsync Client OK!"
fi
